<template>
	<view class="container">
		<view class="search-box">
			<headerSearch bgColor="#F6F6F6" placeholder="搜索"></headerSearch>
		</view>
		<view class="user-num">
			<view class="n-box">
				<view class="num">
					{{count}}
				</view>
				<text>总数用户</text>
			</view>
		</view>
		<view class="list">
			<view v-for="item,index in arrayList" :key="index"  class="item">
				<view  @click="toDetail(item)" class="left">
					<image :src="$img_base_url(item.avatar)" mode="aspectFill"></image>
					<view class="info">
						<view class="name">
							<view class="one-row">{{item.nickname}}</view>
						</view>
						<view class="time">
							开通时间：{{item.createtime}}
						</view>
					</view>
				</view>
				
				<image @click="makePhoneCall(item.mobile)" :src="$img_path('/pagesRegion/1.png')" mode="widthFix"></image>
			</view>
		</view>
		
		<view class="bottom-btn">
			<view class="b-box">
				<button @click="toAdd">开通新社区代理</button>
			</view>
		</view>
	</view>
</template>

<script>
	import * as api from '@/utils/api/index.js'
	import headerSearch from '@/components/header-search/header-search.vue'
	export default {
		components:{
			headerSearch,
		},
		data() {
			return {
				arrayList: [],
				count:''
			};
		},
		onShow() {
			this.shareLists()
		},
		methods:{
			makePhoneCall(phoneNumber){
				uni.makePhoneCall({
					phoneNumber,
				});
			},
			async shareLists() {
				const {
					code,
					data
				} = await api.getAgent()
				if (code == 1) {
					this.arrayList = data.list
					this.count = data.count
				}
			},
			toAdd(){
				uni.navigateTo({
					url:'/pagesRegion/proxy/addNew'
				})
			},
			toDetail(item){
				uni.navigateTo({
					url:`/pagesRegion/proxy/detail?id=` + item.id
				})
			}
		}
	}
</script>
<style>
	page{
		background-color: #FFFFFF;
	}
</style>
<style lang="scss" scoped>
.container{
	padding-bottom: calc(constant(safe-area-inset-bottom) + 140rpx);
	padding-bottom: calc(env(safe-area-inset-bottom) + 140rpx);
	.search-box{
		padding: 14rpx 22rpx 0;
		box-sizing: border-box;
		header-search{
			height: 84rpx;
		}
		/deep/ .search{
			height: 84rpx;
		}
	}
	.user-num{
		padding: 0 22rpx;
		margin-top: 20rpx;
		box-sizing: border-box;
		.n-box{
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 12rpx 2rpx rgba(223,223,223,0.56);
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			border: 2rpx solid #EEEEEE;
			padding: 48rpx 0 46rpx;
			box-sizing: border-box;
			display: flex;
			flex-direction: column;
			align-items: center;
			.num{
				font-weight: bold;
				font-size: 52rpx;
				color: #000000;
				line-height: 74rpx;
			}
			&>text{
				font-weight: bold;
				font-size: 28rpx;
				color: #333333;
				line-height: 40rpx;
				margin-top: 4rpx;
			}
		}
	}
	.list{
		padding-top: 2rpx;
		.item{
			padding: 22rpx 22rpx 22rpx 24rpx;
			box-sizing: border-box;
			border-bottom: 2rpx solid #EEEEEE;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.left{
				display: flex;
				align-items: center;
				image{
					width: 88rpx;
					height: 88rpx;
					border-radius: 50%;
				}
				.info{
					padding-left: 20rpx;
					.name{
						font-weight: bold;
						font-size: 28rpx;
						color: #000000;
						line-height: 40rpx;
					}
					.time{
						font-weight: 400;
						font-size: 24rpx;
						color: #818181;
						line-height: 34rpx;
						margin-top: 4rpx;
					}
				}
			}
			&>image{
				width: 68rpx;
				height: 68rpx;
			}
		}
	}
	
	.bottom-btn{
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
		background-color: #FFFFFF;
		.b-box{
			padding: 20rpx 22rpx;
			box-sizing: border-box;
			button{
				width: 100%;
				height: 96rpx;
				background: linear-gradient( 135deg, #FFA233 0%, #FB4C4C 100%);
				border-radius: 80rpx;
				font-weight: bold;
				font-size: 36rpx;
				color: #FFFFFF;
				line-height: 96rpx;
			}
		}
	}
}
</style>
